package com.imc.api.order.repository;

import com.imc.api.order.pojo.OrderDetail;
import com.imc.api.order.pojo.UserOrgAccount;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

/**
 * Created by tanweiping on 2018/11/28.
 */
@Repository
public interface IUserOrgAccountRepository extends JpaRepository<UserOrgAccount, Integer>, JpaSpecificationExecutor<UserOrgAccount> {
    UserOrgAccount findAllByUserIdAndOrgId(String userId,String orgId);

    @Query(
            nativeQuery = true,
            value="SELECT sum(uoa.lessonAccount) FROM t_user_org_account uoa WHERE uoa.userId = :userId GROUP BY uoa.userId"
    )
    Integer accountByUserId(@Param("userId") String userId);
}
